<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>	
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;
%>
<!DOCTYPE html>
<html>
<head>
<title>个人中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="<%=basePath %>/css/open/mp/common.css" type="text/css">
<link rel="stylesheet" href="<%=basePath %>/css/open/mp/userinfo.css?v=2018031503" type="text/css">
<style type="text/css">
.crmItem,#memberLevelDiv{
	display: none;
}
</style>
</head>
<body>
<div id="container">
    <div class="head" >
    	<div class="company_logo" style="overflow: hidden;width: 80px;float: right;z-index: 99;position: absolute;right: 0;top: 0;">
			<img src="" style="width: 100%;" id="company_logo_thumbnail" class="company_logo_thumbnail">
		</div>
        <img id="portrait" src="<%=basePath %>/images/open/mp/portrait_default.png"/>
        <div id="info">
            <div>
                <span id="realname">--</span>
                <span id="mobile" style="font-size: 12px"></span>
            </div>
           <div id="memberLevelDiv">
               <span>会员等级: </span>
               <span id="memberLevel">--</span>
           </div>
        </div>
        <img id="bg_thumbnail" class="bg_thumbnail" src="" style="position: absolute; width: 100%; height: 100%; z-index: 1;top: 0px;">
    </div>
    <div class="second-row">
        <div>
            <img src="<%=basePath %>/images/open/mp/icon_money.png" />
            <span>储值:</span>
            <span id="balance">--</span>
        </div>
        <div>
            <img src="<%=basePath %>/images/open/mp/icon_point.png" />
            <span>积分:</span>
            <span id="credits">--</span>
        </div>
    </div>
    <div class="list">
        <a href="list/integralList" class="crmItem">
	        <div>
	            <img src="<%=basePath %>/images/open/mp/icon_point.png" />
	            <span data-type="integral">积分明细</span>
	        </div>
        </a>
        <a href="list/moneyList" class="crmItem">
	        <div>
	            <img src="<%=basePath %>/images/open/mp/icon_money.png" />
	            <span data-type="money">储值明细</span>
	        </div>
        </a>
        <a href="list/consumeList" class="crmItem">
	        <div>
	            <img src="<%=basePath %>/images/open/mp/icon_bill.png" />
	            <span data-type="consume">消费明细</span>
	        </div>
        </a>
        <a href="/view/ui/mobileCoupon?customerId=${customerId }&cid=${cid}">
	        <div>
	            <img src="<%=basePath %>/images/open/mp/icon_ticket.png" />
	            <span data-type="coupon">我的优惠券</span>
	        </div>
        </a>
        <a href="list/activityList">
	        <div>
	            <img src="<%=basePath %>/images/open/mp/icon_activity.png" />
	            <span data-type="activity">我的活动</span>
	        </div>
        </a>
        <%-- <div>
            <img src="<%=basePath %>/images/open/mp/icon_activity.png" />
            <span id="logout">退出</span>
        </div> --%>
    </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
var path = "<%=path%>";
var icon = "${icon}";
var nick_name = "${nick_name}";
var appId = "${appId}";
var noncestr = "${noncestr}";
var timestamp = "${timestamp}";
var signature = "${signature}";
wx.config({
    debug: false,
    appId: appId,
    timestamp: timestamp,
    nonceStr: noncestr,
    signature: signature,
    jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage"]
});
wx.ready(function () {
	wx.onMenuShareTimeline({
	    title: '会员中心',
	    link: window.location.href,
	    imgUrl: icon,
	    success: function () {
		},
		cancel: function () {
	    }
	});
	wx.onMenuShareAppMessage({
		title: '会员中心',
		desc: nick_name,
		link: window.location.href,
		imgUrl: icon,
		type: '', // 分享类型,music、video或link，不填默认为link
		dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
		success: function () {
		},
		cancel: function () {
		}
	});
})
function reloadBaseInfo(){
	var baseInfoUrl = path+'/open/me/baseInfo';
	$.ajax({
		url:baseInfoUrl,
		type:"GET",
		timeout: 10000,
		dataType:"jsonp",
		success:function (result) {
			if(result.status == 200){
				console.log(result)
				$('#realname').html(result.realname)
				$('#mobile').html(result.mobile)
				if(result.memberLevel == null || result.memberLevel == ''){
				}else{					
					$('#memberLevel').html(result.memberLevel)
					$('#memberLevelDiv').show();
				}
				if(result.isCRMer == '1'){
					$('.crmItem').show();
				}
				if(typeof(result.headimgurl) != 'undefined' && result.headimgurl != ''){					
					$('#portrait').attr('src',result.headimgurl)
				}
				if(typeof(result.background) != 'undefined' && result.background != ''){					
					$('#bg_thumbnail').attr('src',result.background)
				}
				if(typeof(result.logo) != 'undefined' && result.logo != ''){					
					$('#company_logo_thumbnail').attr('src',result.logo)
				}
				$('#credits').html(result.credits)
				$('#balance').html(result.balance)
			}else if(result.status == 400){
				$.removeCookie('mobile', { path: '/' });
				window.location.href = path+'/open/me';
			}else{
				/* alert(result.message); */
			}
		},
		error:function(result){
			//alert("服务器错误");
		}
	})
}
function checklogin(){
	var baseInfoUrl = path+'/open/me/loginStatus';
	$.ajax({
		url:baseInfoUrl,
		type:"GET",
		timeout: 10000,
		dataType:"jsonp",
		success:function (result) {
			if(result.status == 400){
				$.removeCookie('mobile', { path: '/' });
				window.location.href = path+'/open/me?cid=' + $.cookie('cid');
			}else{
				/* alert(result.message); */
			}
		},
		error:function(result){
			//alert("服务器错误");
		}
	})
}
$(function(){
	/* $('#logout').on('click',function(){
		console.log('ready to logout...');
		var tenant_id = $.cookie('tenant_id');
		$.removeCookie('mobile', { path: '/' });
		$.removeCookie('tenant_id', { path: '/' });
		location.reload();
	}) */
	reloadBaseInfo();
	setInterval("checklogin()",5000);
	
})
</script>
</body>
</html>